<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>循环</title>
</head>
<body>
<p>点击下面的按钮，只要i小于5就会一直循环该代码</p>
<button onclick="myfunction()">点击这里</button>
<p id="demo"></p>
<script>
  // //for in 语句循环遍历对象中的属性
  //for 循环常用于已知循环次数wa
  // var person={fname:"Bill",lname:"Gates",age:56};
  // var x
  // var txt=""
  // for (x in person){
  //   txt=txt + person[x]
  // }
  // document.write(txt);
  //while循环
  function myfunction(){
    var txt="",t=0;
    while (t<5){
      document.write(txt + "该数字为" + t + "<br>")
      t++
    }
    //document.getElementById("demo").innerHTML=txt
  }

</script>

</body>
</html>